package org.ala.tiktools.rpc.netty.handler.ping;

import io.netty.buffer.ByteBuf;
import org.ala.tiktools.rpc.msg.RpcMsgHead;
import org.ala.tiktools.rpc.msg.ping.RpcPingMsg;
import org.ala.tiktools.rpc.netty.handler.IRpcMsgDecoderEncoder;

/**
 * @author ala
 * @date 2025-04-08 11:56
 */
public class RpcPingMsgDecoderEncoder implements IRpcMsgDecoderEncoder<RpcPingMsg> {
    /**
     *  默认实例
     */
    public static RpcPingMsgDecoderEncoder INSTANCE = new RpcPingMsgDecoderEncoder();


    @Override
    public RpcPingMsg decode(RpcMsgHead head, ByteBuf in) {
        return RpcPingMsg.build().head(head);
    }

    @Override
    public void encoder(RpcPingMsg msg, ByteBuf out) {
        out.writeLong(msg.getHead().getId());
        out.writeInt(msg.getHead().getType().getVal());
        out.writeInt(0);
    }
}
